<?php
session_start();

echo "Hello:<input type=text name=sessionuseremail disabled=disabled value='$_SESSION[email]'>";

?>
<html>




<body bgcolor=gray>



<h1><marquee bgcolor=orange>Welcome to The SASystem</marquee></h1>
<?php

	$localhost = "localhost";
        $user = "root";
        $password = "abc123";
	
	


	$connection = @mysql_connect($localhost, $user, $password);

		if(!$connection){
			 die("Can not connect " . mysql_connect_error());
			}
			mysql_select_db("sasystemTables", $connection);
	


	

	/*$Studentname = "SELECT name, UserID, Teacher, School FROM StudentInfo WHERE Name='$_POST[fname]'";
	$result = mysql_query($Studentname, $connection);
	//$row = mysql_fetch_array($result);*/
	
	

	if($_POST['insert'] == 'Save'){

  
  $InsertExperience = "INSERT FieldExperience VALUES ('$_POST[numofrow]', '$_POST[school]', '$_POST[teacher]', '$_SESSION[email]')";
	mysql_query($InsertExperience, $connection);

  $InsertTravel = "INSERT Travel VALUES ('$_SESSION[email]', '$_POST[car]')";
	mysql_query($InsertTravel, $connection);


	//$result = mysql_query($Studentname, $connection);
	//$row = mysql_fetch_array($result);

	echo "ur data is saved";



	
	};

		if($_POST['addTime'] == 'Add Time'){

  
  $InsertConflicts = "INSERT Conflicts VALUES ('$_POST[conflict]', '$_POST[from]', '$_POST[to]','$_POST[day]', '$_POST[cnumofrow]',  '$_SESSION[email]')";
	mysql_query($InsertConflicts, $connection);




	//$result = mysql_query($Studentname, $connection);
	//$row = mysql_fetch_array($result);

	echo "ur data is saved";



	
	};
///////e

if(isset($_POST['experdelete'])){
$DeletQ = "DELETE FROM FieldExperience WHERE FieldExperienceID = '$_POST[hidden]'";
mysql_query($DeletQ, $connection);
};

 if(isset($_POST['experupdate'])){

$UpdateQ = "UPDATE FieldExperience SET mentor='$_POST[mentor]', school='$_POST[sschool]' where FieldExperienceID = '$_POST[hidden]'";
mysql_query($UpdateQ, $connection);



};

///////e





echo "<form action=example1 method=post>";
	$FieldExperienceNumOfRow= "SELECT * FROM FieldExperience";
	$result=mysql_query($FieldExperienceNumOfRow, $connection);
	$num_rows = mysql_num_rows($result)+1;
	
	$ConflictNumOfRow= "SELECT * FROM Conflicts";
	$Cresult=mysql_query($ConflictNumOfRow, $connection);
	$Cnum_rows = mysql_num_rows($Cresult)+1;
	

echo "<input type=text name=numofrow value=".$num_rows.">";
echo "<input type=text name=cnumofrow value=".$Cnum_rows.">";

//echo"</table><input type=submit name=submit value='Add time'><br>";
echo "<center>";




// Table 1 to fill the Classes' Info
echo "<table border=1>
 
   <tr> <th>Student Infromation</th></tr>";
        echo "<td>";

	
	//echo "UserID:<input type=text disabled=disabled name=userID value=" . $row['UserID'] . ">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

		echo"Last experience:<br><br>
	Teacher name<input type=text name=teacher value=".$row['Teacher'].">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	School name&nbsp;&nbsp;&nbsp;<input type=text name=school value=".$row['School']."><br><br>";
//////////////////////////

$Experchedule = mysql_query("SELECT f.*, l.userID FROM FieldExperience as f join Logins as l where l.userID = '$_SESSION[email]' and l.userID = f.userID", $connection);
echo "<center><table border=1>
 <tr>
    
    <th>Teacher</th>
    <th>School</th>
    
    
 </tr>";

   while($row = mysql_fetch_array($Experchedule))
{
  
   
   echo "<tr>";
   
   echo "<td>" . "<input type=text name=mentor value=" . $row['mentor'] . " </td>";
   echo "<td>" . "<input type=text name=sschool value=" . $row['school'] . " </td>";
  

   echo "<td>" . "<input type=text name=hidden disabled=disabled value=" . $row['FieldExperienceID'] . " </td>";
   echo "<td>" . "<input type=submit name=experupdate value=Update>" . "</td>";
   echo "<td>" . "<input type=submit name=experdelete value=Delete>" . "</td>";
   
   
   echo "</tr>";
  

 }

echo "</table></center>";

///////////////////////
        echo "Do you have a car?<input type=radio name=car value=No>No&nbsp;&nbsp;&nbsp; <input type=radio name=car value=Yes>Yes&nbsp;&nbsp;&nbsp;
	<input type=submit name=insert style='color: blue; background-color: orange;' value=Save><br><br><br><br>";
	
	

	

	        echo "What is the type of the conflict?<input type=radio name=conflict value=Class>Class&nbsp;&nbsp;&nbsp; <input type=radio name=conflict value=Work>Work&nbsp;&nbsp;&nbsp;<input type=radio name=conflict value=Preferred>Preferred Off-Time<br><br>";

	/////
	echo "<lable>Days:&nbsp;</lable>";
	
	
	echo "<input type=radio name=day value=Monday>Mon&nbsp;&nbsp;";
	echo "<input type=radio name=day value=Tuseday>&nbsp;Tue&nbsp;&nbsp;";
	echo "<input type=radio name=day value=Wednesday>Wed&nbsp;&nbsp;";
	echo "<input type=radio name=day value=Thursday>&nbsp;Thu&nbsp;&nbsp;";
	echo "<input type=radio name=day value=Friday>&nbsp;&nbsp;&nbsp;Fri<br><br>";
	

        echo "Time:&nbsp;&nbsp; <select name=from> <option value=From>From</optioin>";
	echo"<option value=6:00AM>6:00 AM</optioin> <option value=7:00AM>7:00 AM</optioin> ";
	echo"<option value=8:00AM>8:00 AM</optioin> <option value=9:00AM>9:00 AM</optioin> <option value=10:00AM>10:00 AM</optioin>";
	echo"<option value=11:00AM>11:00 AM</optioin> <option value=12:00PM>12:00 PM</optioin> <option value=1:00PM>1:00 PM</optioin>";
	echo"<option value=2:00PM>2:00 PM</optioin> <option value=3:00PM>3:00 PM</optioin>";
	
	echo"</select>  ";
        echo"<select name=to> <option value=To>To</optioin>";
	echo"<option value=7:00AM>7:00 AM</optioin>";
	echo"<option value=8:00AM>8:00 AM</optioin> <option value=9:00AM>9:00 AM</optioin> <option value=10:00AM>10:00 AM</optioin>";
	echo"<option value=11:00AM>11:00 AM</optioin> <option value=12:00PM>12:00 PM</optioin> <option value=1:00PM>1:00 PM</optioin>";
	echo"<option value=2:00PM>2:00 PM</optioin> <option value=3:00PM>3:00 PM</optioin> <option value=4:00PM>4:00 PM</optioin>";
        
	
	echo"</select>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=submit name=addTime style='color: blue; background-color: orange;' value='Add Time'><br><br>";

/////////////C

$Conchedule = mysql_query("SELECT c.*, l.userID FROM Conflicts as c join Logins as l where l.userID = '$_SESSION[email]' and l.userID = c.userID", $connection);
echo "<table border=1>
 <tr>
    
    <th>Conflict Typ</th>
    <th>Conflict Starting Time</th>
    <th>Conflict Ending Time</th>
    <th>Conflict Day</th>
    <th>Conflict ID</th>
    
    
 </tr>";

   while($row = mysql_fetch_array($Conchedule))
{
  
   
   echo "<tr>";
   
   echo "<td>" . "<input type=text name=contype value=" . $row['conflictType'] . " </td>";
   echo "<td>" . "<input type=text name=constartime value=" . $row['conflictStartTime'] . " </td>";
   echo "<td>" . "<input type=text name=conendtime value=" . $row['conflictStopTime'] . " </td>";
   echo "<td>" . "<input type=text size=30 name=conday value=" . $row['conflictDay'] . " </td>";
   //echo "<td>" . "<input type=text name=conid value=" . $row['ConflictID'] . " </td>";

  

   echo "<td>" . "<input type=text disabled=disabled name=chidden value=" . $row['ConflictID'] . " </td>";
   echo "<td>" . "<input type=submit name=conupdate value=Update>" . "</td>";
   echo "<td>" . "<input type=submit name=condelete value=Delete>" . "</td>";
   
   
   echo "</tr>";
  

 }

echo "</table>";

/////////////C

        
	
	
echo" </td>";

echo "</table><br><br>";




echo "</center>";
echo "</form>";


if(isset($_POST['print']))
{ 
       // $_POST['fname']=$_POST['fname'];
	echo "hello";
	//header('Location: fortest');


}
?>

</body>


</html>
